<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
  <title>添加食材 - 食物食材食品基本信息Web系统</title>
  <link rel="stylesheet" href="css/style.css">
  <script>
    if (!sessionStorage.getItem('isLoggedIn')) {
      window.location.href = 'login.html';
    }
  </script>
</head>
<body>
  <div class="bg"></div>
  <div class="bg bg2"></div>
  <div class="bg bg3"></div>
  <header>
    <h1>食物食材食品基本信息Web系统</h1>
    <nav>
      <div class="user-menu" id="userMenu">
        <img src="img/avatar.png" alt="头像" class="avatar" id="userAvatar">
        <span class="username" id="usernameDisplay">用户</span>
        <span class="dropdown-arrow">&#9662;</span>
        <div class="dropdown-menu" id="dropdownMenu">
          <a href="#" id="profileLink"><span class="menu-icon">&#8962;</span> 个人空间</a>
          <a href="login.html" id="logout"><span class="menu-icon">&#9906;</span> 退出登录</a>
        </div>
      </div>
    </nav>
  </header>
  <main>
    <a href="index.html" class="back-home-btn"><span>返回首页</span></a>
    <section>
      <h2>添加食材基本信息</h2>
      <form id="addIngredientForm" enctype="multipart/form-data" class="data-form">
        <div class="form-row">
          <div class="form-group">
            <label for="ingredientName"><span style="color:red">*</span>食材名称：</label>
            <input type="text" id="ingredientName" name="ingredientName" required>
          </div>
          <div class="form-group">
            <label for="category"><span style="color:red">*</span>食材分类：</label>
            <select id="category" name="category" required>
              <option value="">请选择分类</option>
              <option value="主食-米面五谷">主食-米面五谷</option>
              <option value="蔬菜-叶瓜果">蔬菜-叶瓜果</option>
              <option value="蔬菜-根茎菌">蔬菜-根茎菌</option>
              <option value="肉食-畜">肉食-畜</option>
              <option value="肉食-禽">肉食-禽</option>
              <option value="水产品-淡水">水产品-淡水</option>
              <option value="水产品-海产">水产品-海产</option>
              <option value="水果">水果</option>
              <option value="干货-山珍海味">干货-山珍海味</option>
              <option value="腌漬食品">腌漬食品</option>
              <option value="奶制品">奶制品</option>
              <option value="酒类">酒类</option>
              <option value="饮料">饮料</option>
              <option value="调料">调料</option>
              <option value="熟食">熟食</option>
              <option value="包装方便食材">包装方便食材</option>
              <option value="珍稀食材">珍稀食材</option>
            </select>
          </div>
        </div>
        <div class="form-row">
          <div class="form-group">
            <label for="origin"><span style="color:red">*</span>产地：</label>
            <input type="text" id="origin" name="origin" required>
          </div>
          <div class="form-group">
            <label for="productionDate"><span style="color:red">*</span>出产日期：</label>
            <input type="date" id="productionDate" name="productionDate" required>
          </div>
        </div>
        <div class="form-row">
          <div class="form-group">
            <label for="producer"><span style="color:red">*</span>生产单位：</label>
            <input type="text" id="producer" name="producer" required>
          </div>
          <div class="form-group">
            <label for="price"><span style="color:red">*</span>交易价格：</label>
            <input type="text" id="price" name="price" placeholder="如：3.5元/斤" required>
          </div>
        </div>
        <div class="form-row">
          <div class="form-group">
            <label for="supplier"><span style="color:red">*</span>供货商：</label>
            <input type="text" id="supplier" name="supplier" required>
          </div>
          <div class="form-group">
            <label for="photo"><span style="color:red">*</span>照片：</label>
            <input type="file" id="photo" name="photo" accept="image/*" required>
          </div>
        </div>
        <div class="form-row">
          <div class="form-group full-width">
            <label for="description">介绍：</label>
            <textarea id="description" name="description" rows="4" placeholder="详细描述食材的特点、营养价值等"></textarea>
          </div>
        </div>
        <div class="form-actions">
          <button type="submit" class="btn btn-primary">保存食材信息</button>
          <button type="button" class="btn btn-secondary" id="resetBtn">重置表单</button>
        </div>
      </form>
    </section>
    
    <section id="successMessage" style="display: none;">
      <div class="success-alert">
        <h3>添加成功！</h3>
        <p>食材信息已成功保存到数据库。</p>
        <button class="btn btn-primary" onclick="location.reload()">继续添加</button>
        <a href="search.html" class="btn btn-secondary">查看数据</a>
      </div>
    </section>
  </main>
  <footer>
    <p>&copy; 2025 食物食材食品基本信息Web系统</p>
  </footer>
  <script src="js/add_ingredient.js"></script>
  <script src="js/user_menu.js"></script>
</body>
</html> 